package com.poorstu.dao.impl;

import java.util.List;

import com.common.base.dao.impl.BaseDaoImpl;
import com.common.base.model.PaginationSupport;
import com.poorstu.dao.LeaseDao;
import com.poorstu.model.LeaseMod;
import com.poorstu.model.LoadMoneyMod;
import com.poorstu.model.RoleMod;

public class LeaseDaoImpl extends BaseDaoImpl implements LeaseDao {
	
	
	public void leaseAdd(LeaseMod lease) {
		super.save(lease);
	}

	public List<LeaseMod> leaseMag() {
		return super.findAll("LeaseMod");
	}

	public int leaseDelete(List<LeaseMod> leaseList) {
		 int a=0;
		  try{
			super.deleteAll(leaseList);
		   a=1;
			}catch(Exception e){
				e.printStackTrace();
				return a;
			}
			return a;
		}

	 
   public LeaseMod selLeaseById(int leaseId) {
		
		return (LeaseMod)super.findByHql("from LeaseMod where leaseId="+leaseId).get(0);
	}

   
	public void changeLease(LeaseMod lease) {
		
		 super.saveOrUpdate(lease);
	}
	
	
	public PaginationSupport getLeaseByPage(String where,
			String orderField, String order, Integer startIndex,
			Integer pageSize) {
		PaginationSupport ps;
		try{
			ps = super.findByWhereOrderBy(LeaseMod.class.getName(), where, orderField, order, startIndex, pageSize);
		}
		catch(Exception e)
		{
			e.printStackTrace();
			return null;
			
		}
		return ps;
	}

	public List<LoadMoneyMod> getLoadMoney() {
		return super.findAll("LoadMoneyMod");
	}

	public void saveLoadMoney(LoadMoneyMod loadMoney) {

		super.save(loadMoney);
	}

	public LoadMoneyMod selectLoadMoneyById(int moneyId) {
		return (LoadMoneyMod)super.findByHql("from LoadMoneyMod where moneyId="+moneyId).get(0);
	}

	public void updateLoadMoney(LoadMoneyMod loadMoney) {
		super.merge(loadMoney);
	}

	public void deleteLoadMoney(List<LoadMoneyMod> loadMoneyList) {
		super.deleteAll(loadMoneyList);
	}
	
	
	
	
	
	
}
